
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.credsoft.copcred.visao.action;

import br.com.credsoft.copcred.model.vo.Menu;
import br.com.credsoft.copcred.model.vo.Usuario;
import br.com.credsoft.copcred.negocio.bo.UsuarioBo;
import br.gov.caixa.gisutsa.framework.tapiocaframework.web.struts2.AbstractAction;
import java.security.Principal;
import java.util.List;
import org.apache.struts2.interceptor.PrincipalAware;
import org.apache.struts2.interceptor.PrincipalProxy;

/**
 *
 * @author c090347
 */
public class PrincipalAction extends AbstractAction implements PrincipalAware{

    private static final long serialVersionUID = -125143074805224576L;
    /****************************************************************/
    private Principal principal;
    private UsuarioBo usuarioBo;

    public void setPrincipalProxy(PrincipalProxy principalProxy) {
        this.principal = principalProxy.getUserPrincipal();
    }

    public void setUsuarioBo(UsuarioBo usuarioBo) {
        this.usuarioBo = usuarioBo;
    }

    public String login() {
        Usuario usuario = usuarioBo.getByLogin(this.principal.getName());
        List<Menu> menus = usuarioBo.getMenuUsuario(usuario);
        this.httpSession.put("menu", menus);
        this.httpSession.put("usuario", usuario);
        return SUCCESS;
    }

    /***************    GETTER'S AND SETTER'S   ********************/
    

}
